home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20000824-20010305 / 000156_news@columbia.edu _Fri Dec 29 07:42:35 2000.msg < prev    next >
Internet Message Format  |  2020-01-01  |  4KB

  1. Return-Path: <news@columbia.edu>
  2. Received: from watsun.cc.columbia.edu (watsun.cc.columbia.edu [128.59.39.2])
  3.     by monire.cc.columbia.edu (8.9.3/8.9.3) with ESMTP id HAA20734
  4.     for <kermit.misc@cpunix.cc.columbia.edu>; Fri, 29 Dec 2000 07:42:35 -0500 (EST)
  5. Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.59.30])
  6.     by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id HAA16674
  7.     for <kermit.misc@watsun.cc.columbia.edu>; Fri, 29 Dec 2000 07:42:35 -0500 (EST)
  8. Received: (from news@localhost)
  9.     by newsmaster.cc.columbia.edu (8.9.3/8.9.3) id HAA24572
  10.     for kermit.misc@watsun.cc.columbia.edu; Fri, 29 Dec 2000 07:30:41 -0500 (EST)
  11. X-Authentication-Warning: newsmaster.cc.columbia.edu: news set sender to <news> using -f
  12. From: Igor Sobrado <sobrado@string1.ciencias.uniovi.es>
  13. Subject: Re: A wish for the FTP-client
  14. Date: 29 Dec 2000 12:29:19 GMT
  15. Organization: Universidad de Oviedo
  16. Message-ID: <92i02v$m4u$1@news01.si.uniovi.es>
  17. To: kermit.misc@columbia.edu
  18.  
  19. Frank da Cruz <fdc@watsun.cc.columbia.edu> wrote:
  20. > In article <3A4BA47C.53C64EBA@srv.net>, Kevin Handy  <kth@srv.net> wrote:
  21. > : Frank da Cruz wrote:
  22. > : > ...  How do you convert a
  23. > : > struct tm to a time_t in a reliable way? -- i.e. without writing code to
  24. > : > count days, months, years, leap years, leap seconds, and all the rest,
  25. > : > taking each machine's architecture into account.  I'm sure I must have
  26. > : > overlooked something obvious -- feel free to embarrass me.
  27.  
  28. I agree with you, C-Kermit is really portable to a lot of different
  29. machine architectures and this important feature should not be ignored
  30. when developers improve its functionality.
  31.  
  32. > : Under *nix, I believe the function to use is mktime
  33. > : 
  34. > :     time_t mktime(struct tm *timeptr)
  35.  
  36. It is right, I think it is the only way to get it in a portable way.
  37.  
  38. > 1. The first place I looked (SunOS) doesn't have it.  However, must other
  39. >    UNIX OS's do have it.  But...
  40.  
  41. It should. At least in recent releases of SunOS, a description of this
  42. function can be found in mktime(3C), that is, in the C Library
  43. Functions section of the manual. Probably you are looking in a
  44. workstation where Solaris is not fully installed (perhaps a final
  45. user installation, not a developer one).
  46.  
  47. > 2. Doesn't do what you want.  "In addition to computing the calendar time,
  48. >    mktime() normalizes  the supplied tm structure" -- applies timezone
  49. >    conversions, etc.  The problem there is, of course, we don't know, and
  50. >    have no way to find out, the server's timezone, and even if we knew it,
  51. >    what the rules are to convert to our own.  The struct tm is *already* in
  52. >    GMT/UTC, and should not be converted to it again.
  53. >
  54. > Thus the resulting file date won't be what you want.  I think the object
  55. > of copying the server's MDTM is so update can work in both directions.  If
  56. > we use mktime(), I think the result will have up to 24 hours of randomness
  57. > added or subtracted.  Am I missing something?
  58.  
  59. As you noted, the FTP-server provides the time in UTC/GMT, all
  60. Unix boxes work with that standard convention. The second (incorrect)
  61. conversion to UTC is made locally by the host where C-Kermit
  62. is installed because mktime(3C) supposes that the tm structure is
  63. in local format, not it UTC. Why not calculate the UTC offset for
  64. the time (as if it is in local format) and "correct" the time
  65. either before converting it to a time_t structure or after that?
  66.  
  67. Best regards,
  68. Igor.
  69.  
  70. -- 
  71. Igor Sobrado, UK34436 - sobrado@acm.org